<template>
  <view :id="'box_pos_'+index">
    <view class="solid-bottom fu-goods-line" @click.stop="navToDetail(item)">
      <view class="block-200 margin-right-sm">
        <image :src="item.thumb" mode="aspectFill" lazy-load></image>
      </view>
      <view class="content">
        <view class="text-df text-333 text-cut-2">
          <block v-if="item.goods_label">
            <text class="bg-theme text-white fu-fs24 radius-8 margin-right-xs" v-for="(labelItem, labelIndex) in item.goods_label" :key="labelIndex">{{ labelItem }}</text>
          </block>
          {{ item.name }}
        </view>
        <!-- <view class="text-sm text-cut">{{ item.keywords }}</view> -->
		<view class="flex justify-between align-center">
		  <!-- <text class="text-through text-sm text-price text-999">{{ item.market_price }}</text> -->
		  <text class="text-sm text-999">销量{{ item.sales_sum | formatNumber('万') }}件</text>
		</view>
        <!-- <view class=""> -->
          <view class="flex  justify-between">
            <view class="flex text-prices text-bold align-end">
				<text style="font-size: 24rpx;">会员价</text>
              <!-- <text class="text-price text-bold text-sm"></text> -->
              <text class="text-bold text-lg" style="font-size: 32rpx;">￥{{ item | filterGoodsPrice }}</text>
            <view class="margin-left-xs" v-if="item.discounts && Number(item.discounts)">
                <tag-line leftText="返" :rightText="item.discounts"></tag-line>
              </view>
            </view>
           
            </view>
  
          <!-- </view> -->
  
         
        </view>
        <!-- v-if="Number(item.share_award_money)" -->
        <!-- <tag-fire :info="item" v-if="Number(item.share_award_money)"></tag-fire> -->
      </view>
    </view>
  </view>
</template>
<script>
  import tagLine from '@/pages/goods/components/tag-line/tag-line.vue';
  import tagFire from '@/pages/goods/components/tag-fire/tag-fire.vue';
  export default {
    components: {
    	tagLine,
    	tagFire
    },
    props: {
      item: {
        type: Object,
        default() {
          return {}
        }
      },
      index: {
        type: Number,
        default: 0
      }
    },
    methods: {
      // 加入购物车
      addCart(item, index) {
        this.$util.actionAuth(() => {
          const data = {
            num: 1,
            goods_id: item.id,
          };
          if (item.sku_id) {
            data.sku_id = item.sku_id;
          }
          this.$api.post(global.apiUrls.postGoodsAddToCart, data).then((res) => {
            if (res.data.code == 1) {
              this.$emit('createAnimate', {item, index})
              // this.createAnimate(item, index);
              this.$message.info("加入购物车成功");
              this.$store.dispatch('getCartList');
              // uni.$emit("updateCart");
            } else {
              this.$message.info(res.data.msg);
            }
          });
        });
      },
      /**
       * @event
       * @description 去商品详情
       */
      navToDetail(item) {
        this.$urouter.navigateTo({
          url: '/pages/goods/goodsdetail/goods-detail/index',
          params: {
            sku_id: item.sku_id || 0,
            goods_id: item.id
          }
        });
      },
    },
  }
</script>

<style lang="scss" scoped>
  // 商品卡片line
  .fu-goods-line {
    /* min-height: 570rpx; */
    padding: 20rpx;
    border-radius: 24rpx;
    overflow: hidden;
    background-color: #ffffff;
    margin-top: 20rpx;
    display: flex;
  
    .block-200 {
      width: 200rpx;
      height: 200rpx;
      border-radius: 6rpx;
      background-color: #eeeeee;
  
      image {
        width: 100%;
        height: 100%;
        border-radius: 6rpx;
      }
    }
  
    .content {
      flex: 1;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }
  }
</style>
